<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      width="35%"
      class="abow_dialog"
      @close="resetForm"
    >
      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="120px" class="demo-ruleForm">
        <el-row>
          <el-col :span="12">
            <el-form-item label="方案名称" prop="name">
              <el-input v-model="ruleForm.name" size="mini" clearable placeholder="请输入方案名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态" prop="status">
              <el-radio v-model="ruleForm.status" :label="1">正常</el-radio>
              <el-radio v-model="ruleForm.status" :label="0">禁用</el-radio>
            </el-form-item>
          </el-col>
          <!-- 峰时间段 -->
          <el-col :span="24">
            <el-form-item label="峰时间段1" prop="fengBegin1">
              <el-col :span="12">
                <el-form-item prop="fengBegin1">
                  <el-time-select
                    v-model="ruleForm.fengBegin1"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item prop="fengEnd1">
                  <el-time-select
                    v-model="ruleForm.fengEnd1"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.fengBegin1
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="峰时间段2">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.fengBegin2"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.fengEnd2"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.fengBegin2
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="峰时间段3">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.fengBegin3"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.fengEnd3"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.fengBegin3
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="峰时间段4">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.fengBegin4"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.fengEnd4"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.fengBegin4
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <!-- 平时间段 -->
          <el-col :span="24">
            <el-form-item label="平时间段1" prop="pingBegin1">
              <el-col :span="12">
                <el-form-item prop="pingBegin1">
                  <el-time-select
                    v-model="ruleForm.pingBegin1"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item prop="pingEnd1">
                  <el-time-select
                    v-model="ruleForm.pingEnd1"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.pingBegin1
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="平时间段2">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.pingBegin2"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.pingEnd2"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.pingBegin2
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="平时间段3">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.pingBegin3"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.pingEnd3"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.pingBegin3
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="平时间段4">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.pingBegin4"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.pingEnd4"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.pingBegin4
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <!-- 谷时间段 -->
          <el-col :span="24">
            <el-form-item label="峰时间段1" prop="guBegin1">
              <el-col :span="12">
                <el-form-item prop="guBegin1">
                  <el-time-select
                    v-model="ruleForm.guBegin1"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item prop="fengEnd1">
                  <el-time-select
                    v-model="ruleForm.guEnd1"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.guBegin1
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="峰时间段2">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.guBegin2"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.guEnd2"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.guBegin2
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="峰时间段3">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.guBegin3"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.guEnd3"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.guBegin3
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="峰时间段4">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.guBegin4"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.guEnd4"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.guBegin4
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <!-- 尖时间段 -->
          <el-col :span="24">
            <el-form-item label="尖时间段1" prop="jianBegin1">
              <el-col :span="12">
                <el-form-item prop="jianBegin1">
                  <el-time-select
                    v-model="ruleForm.jianBegin1"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item prop="jianEnd1">
                  <el-time-select
                    v-model="ruleForm.jianEnd1"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.jianBegin1
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="尖时间段2">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.jianBegin2"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.jianEnd2"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.jianBegin2
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="尖时间段3">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.jianBegin3"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.jianEnd3"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.jianBegin3
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="尖时间段4">
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.jianBegin4"
                    placeholder="开始时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30'
                    }"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item>
                  <el-time-select
                    v-model="ruleForm.guEnd4"
                    placeholder="结束时间"
                    size="mini"
                    style="width: 100%;"
                    :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '23:30',
                      minTime: ruleForm.guBegin4
                    }"
                  />
                </el-form-item>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="峰电价(元)" prop="feng_price">
              <el-input-number v-model="ruleForm.feng_price" style="width: 100%;" size="mini" :min="0" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="平电价(元)" prop="ping_price">
              <el-input-number v-model="ruleForm.ping_price" style="width: 100%;" size="mini" :min="0" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="谷电价(元)" prop="gu_price">
              <el-input-number v-model="ruleForm.gu_price" style="width: 100%;" size="mini" :min="0" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尖电价(元)" prop="jian_price">
              <el-input-number v-model="ruleForm.jian_price" style="width: 100%;" size="mini" :min="0" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="站点需量(kVA)">
              <el-input-number v-model="ruleForm.station_demand" style="width: 100%;" size="mini" :min="0" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="需量电价(元)">
              <el-input-number v-model="ruleForm.demand_price" style="width: 100%;" size="mini" :min="0" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="站点容量(kVA)">
              <el-input-number v-model="ruleForm.station_capacity" style="width: 100%;" size="mini" :min="0" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="容量电价(元)">
              <el-input-number v-model="ruleForm.capacity_price" style="width: 100%;" size="mini" :min="0" />
            </el-form-item>
          </el-col>
        </el-row>
        <!--<el-form-item style="display: flex;justify-content: flex-end">
          <el-button type="primary" @click="resetForm">取消</el-button>
          <el-button type="primary" @click="addOrEdit">确定</el-button>
        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="resetForm">取消</el-button>
        <el-button type="primary" @click="addOrEdit">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { createQuote, updateQuote, detailQuote } from '@/api/fileManage'
export default {
  name: 'detail',
  props: {
    dialogVisible: {
      type: Boolean,
      default: true
    },
    title: {
      type: String,
      default: '新增'
    },
    id: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      ruleForm: {
        name: '', // 方案名称
        status: 1, // 状态 ： 1正常， 0：禁用
        fengBegin1: '', // 峰时间段
        fengEnd1: '', // 峰时间段
        fengBegin2: '',
        fengEnd2: '',
        fengBegin3: '',
        fengEnd3: '',
        fengBegin4: '',
        fengEnd4: '',
        pingBegin1: '', // 平时间段
        pingEnd1: '', // 平时间段
        pingBegin2: '',
        pingEnd2: '',
        pingBegin3: '',
        pingEnd3: '',
        pingBegin4: '',
        pingEnd4: '',
        guBegin1: '', // 谷时间段
        guEnd1: '', // 谷时间段
        guBegin2: '',
        guEnd2: '',
        guBegin3: '',
        guEnd3: '',
        guBegin4: '',
        guEnd4: '',
        jianBegin1: '', // 尖时间段
        jianEnd1: '', // 尖时间段
        jianBegin2: '',
        jianEnd2: '',
        jianBegin3: '',
        jianEnd3: '',
        jianBegin4: '',
        jianEnd4: '',
        feng_price: '', // 峰电价
        ping_price: '', // 平电价
        gu_price: '', // 谷电价
        jian_price: '', // 尖电价
        station_demand: '', // 站点需量
        demand_price: '', // 需量电价
        station_capacity: '', // 站点容量
        capacity_price: '' // 容量电价
      },
      rules: {
        name: [
          { required: true, message: '请输入设备名称', trigger: 'blur' }
        ],
        status: [
          { required: true, message: '请选择电价方案状态', trigger: 'blur' }
        ],
        fengBegin1: [
          { required: true, message: '请选择峰时间段', trigger: 'blur' }
        ],
        fengEnd1: [
          { required: true, message: '请选择峰时间段', trigger: 'blur' }
        ],
        pingBegin1: [
          { required: true, message: '请选择平时间段', trigger: 'blur' }
        ],
        pingEnd1: [
          { required: true, message: '请选择平时间段', trigger: 'blur' }
        ],
        guBegin1: [
          { required: true, message: '请选择谷时间段', trigger: 'blur' }
        ],
        guEnd1: [
          { required: true, message: '请选择谷时间段', trigger: 'blur' }
        ],
        jianBegin1: [
          { required: true, message: '请选择尖时间段', trigger: 'blur' }
        ],
        jianEnd1: [
          { required: true, message: '请选择尖时间段', trigger: 'blur' }
        ],
        feng_price: [
          { required: true, message: '请输入峰电价', trigger: 'blur' }
        ],
        ping_price: [
          { required: true, message: '请输入平电价', trigger: 'blur' }
        ],
        gu_price: [
          { required: true, message: '请输入谷电价', trigger: 'blur' }
        ],
        jian_price: [
          { required: true, message: '请输入尖电价', trigger: 'blur' }
        ]
      },
      optionsType: [], // 设备类型 --- 设备类型关联指标组
      optionsSite: [], // 站点列表 --- 站点关联分组档案和关联摄像
      optionsGroup: [], // 分组档案
      optionsCamera: [], // 关联摄像
      optionsTarget: [] // 关联指标组
    }
  },
  created() {
    // 编辑
    if (this.id) {
      // this.ruleForm.pid = this.id
      if (this.title === '新增') {
        this.ruleForm.pid = this.id
      } else {
        this.getDetailById(this.id)
      }
    }
  },
  methods: {
    // 获取详情
    getDetailById(id) {
      detailQuote({ id }).then(res => {
        this.ruleForm = {
          id: res.data.id,
          name: res.data.name, // 方案名称
          status: res.data.status, // 状态 ： 1正常， 0：禁用
          fengBegin1: res.data.feng[0].begin, // 峰时间段
          fengEnd1: res.data.feng[0].end, // 峰时间段
          fengBegin2: res.data.feng[1].begin,
          fengEnd2: res.data.feng[1].end,
          fengBegin3: res.data.feng[2].begin,
          fengEnd3: res.data.feng[2].end,
          fengBegin4: res.data.feng[3].begin,
          fengEnd4: res.data.feng[3].end,
          pingBegin1: res.data.ping[0].begin, // 平时间段
          pingEnd1: res.data.ping[0].end, // 平时间段
          pingBegin2: res.data.ping[1].begin,
          pingEnd2: res.data.ping[1].end,
          pingBegin3: res.data.ping[2].begin,
          pingEnd3: res.data.ping[2].end,
          pingBegin4: res.data.ping[3].begin,
          pingEnd4: res.data.ping[3].end,
          guBegin1: res.data.gu[0].begin, // 谷时间段
          guEnd1: res.data.gu[0].end, // 谷时间段
          guBegin2: res.data.gu[1].begin,
          guEnd2: res.data.gu[1].end,
          guBegin3: res.data.gu[2].begin,
          guEnd3: res.data.gu[2].end,
          guBegin4: res.data.gu[3].begin,
          guEnd4: res.data.gu[3].end,
          jianBegin1: res.data.jian[0].begin, // 尖时间段
          jianEnd1: res.data.jian[0].end, // 尖时间段
          jianBegin2: res.data.jian[1].begin,
          jianEnd2: res.data.jian[1].end,
          jianBegin3: res.data.jian[2].begin,
          jianEnd3: res.data.jian[2].end,
          jianBegin4: res.data.jian[3].begin,
          jianEnd4: res.data.jian[3].end,
          feng_price: res.data.feng_price, // 峰电价
          ping_price: res.data.ping_price, // 平电价
          gu_price: res.data.gu_price, // 谷电价
          jian_price: res.data.jian_price, // 尖电价
          station_demand: res.data.station_demand, // 站点需量
          demand_price: res.data.demand_price, // 需量电价
          station_capacity: res.data.station_capacity, // 站点容量
          capacity_price: res.data.capacity_price // 容量电价
        }
      })
    },
    // 新增、编辑
    addOrEdit() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          // 操作提交的数据
          const obj = {
            feng: [
              {
                begin: this.ruleForm.fengBegin1,
                end: this.ruleForm.fengEnd1
              },
              {
                begin: this.ruleForm.fengBegin2,
                end: this.ruleForm.fengEnd2
              },
              {
                begin: this.ruleForm.fengBegin3,
                end: this.ruleForm.fengEnd3
              },
              {
                begin: this.ruleForm.fengBegin4,
                end: this.ruleForm.fengEnd4
              }
            ],
            status: this.ruleForm.status,
            jian: [
              {
                begin: this.ruleForm.jianBegin1,
                end: this.ruleForm.jianEnd1
              },
              {
                begin: this.ruleForm.jianBegin2,
                end: this.ruleForm.jianEnd2
              },
              {
                begin: this.ruleForm.jianBegin3,
                end: this.ruleForm.jianEnd3
              },
              {
                begin: this.ruleForm.jianBegin4,
                end: this.ruleForm.jianEnd4
              }
            ],
            ping: [
              {
                begin: this.ruleForm.pingBegin1,
                end: this.ruleForm.pingEnd1
              },
              {
                begin: this.ruleForm.pingBegin2,
                end: this.ruleForm.pingEnd2
              },
              {
                begin: this.ruleForm.pingBegin3,
                end: this.ruleForm.pingEnd3
              },
              {
                begin: this.ruleForm.pingBegin4,
                end: this.ruleForm.pingEnd4
              }
            ],
            gu: [
              {
                begin: this.ruleForm.guBegin1,
                end: this.ruleForm.guEnd1
              },
              {
                begin: this.ruleForm.guBegin2,
                end: this.ruleForm.guEnd2
              },
              {
                begin: this.ruleForm.guBegin3,
                end: this.ruleForm.guEnd3
              },
              {
                begin: this.ruleForm.guBegin4,
                end: this.ruleForm.guEnd4
              }
            ],
            name: this.ruleForm.name,
            feng_price: this.ruleForm.feng_price, // 峰电价
            ping_price: this.ruleForm.ping_price, // 平电价
            gu_price: this.ruleForm.gu_price, // 谷电价
            jian_price: this.ruleForm.jian_price, // 尖电价
            station_demand: this.ruleForm.station_demand, // 站点需量
            demand_price: this.ruleForm.demand_price, // 需量电价
            station_capacity: this.ruleForm.station_capacity, // 站点容量
            capacity_price: this.ruleForm.capacity_price // 容量电价
          }
          if (this.title === '编辑') {
            //  是编辑
            obj.id = this.ruleForm.id
            updateQuote(obj).then(res => {
              this.$message({
                message: '修改成功',
                type: 'success'
              })
              this.$emit('confirm')
            })
          } else {
            //  是新增
            createQuote(obj).then(res => {
              this.$message({
                message: '新增成功',
                type: 'success'
              })
              this.$emit('confirm')
            })
          }
        }
      })
    },
    // 表单重置
    resetForm() {
      this.$refs['ruleForm'].resetFields()
      this.$emit('close')
    }
  }
}
</script>

<style lang="scss" scoped>
  ::v-deep.el-dialog {
    margin: 5vh auto !important;
  }

  ::v-deep .el-dialog__body {
    height: 70vh;
    overflow: auto;
  }
</style>
